package creation_patterns.factory_method_pattern.concrete_factory;

import creation_patterns.factory_method_pattern.abstract_product.Food;
import creation_patterns.factory_method_pattern.concrete_product.Noodles;
import creation_patterns.factory_method_pattern.factory.FoodFactory;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class NoodlesFactory implements FoodFactory {
    public List<Food> noodlesBeanList = new CopyOnWriteArrayList<>();
    @Override
    public Food createFoodBean() {
        if(noodlesBeanList.isEmpty()){
            noodlesBeanList.add(new Noodles());
        }
        return noodlesBeanList.get(0);
    }
}
